//
//  PPInfoIconCell.m
//  PropertyManage
//
//  Created by Dreamsoul on 15-3-25.
//  Copyright (c) 2015年 com.lab603.mc. All rights reserved.
//

#import "PPMeInfoIconCell.h"
#import "PPPicturesView.h"
#import "PPPicture.h"
#import "PPMeInfoIconCellFrame.h"
#import "PPMe.h"
@interface PPMeInfoIconCell()
@property (nonatomic,weak)UILabel *titleLabel;
@end

@implementation PPMeInfoIconCell
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *ID = @"meInfoIconCell";
    PPMeInfoIconCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[PPMeInfoIconCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectedBackgroundView = [[UIView alloc] init];
        //设置背景图片
        UIImageView *backgroundView = [[UIImageView alloc] init];
        backgroundView.image = [UIImage resizedImageWithName:@"timeline_card_top_background"];
        backgroundView.highlightedImage = [UIImage resizedImageWithName: @"timeline_card_top_background_highlighted"];
        [self.contentView addSubview:backgroundView];
        self.backgroundView = backgroundView;
        //设置标题文字
        UILabel *titleLabel = [[UILabel alloc] init];
        [titleLabel setBackgroundColor:[UIColor clearColor]];
        [titleLabel setTextColor:[UIColor blackColor]];
        titleLabel.numberOfLines = 0;
        titleLabel.font = [UIFont systemFontOfSize:15.0];
        [self.backgroundView addSubview:titleLabel];
        self.titleLabel = titleLabel;
        //设置图片
        PPPicturesView *iconView = [[PPPicturesView alloc] init];
        [self addSubview:iconView];
        self.iconView = iconView;
    }
    return self;
}

- (void)setInfoIconCellF:(PPMeInfoIconCellFrame *)infoIconCellF{
    
    _infoIconCellF = infoIconCellF;
    //设置frame
    self.iconView.frame = infoIconCellF.iconF;
    self.titleLabel.frame = infoIconCellF.titleF;
    self.backgroundView.frame = infoIconCellF.backgroundViewF;
    //设置数据
    //PPMe *me = infoIconCellF.me;
    self.titleLabel.text = infoIconCellF.me.titleString;
    //设置图片(由于添加了相册浏览器功能)
    NSMutableArray *picturesArray = [[NSMutableArray alloc] init];
    NSString *iconString = [NSString stringWithFormat:@"%@/static/%@",BaseUrl,infoIconCellF.me.icon];
    PPPicture *iconPicture = [[PPPicture alloc] init];
    iconPicture.picture = iconString;
    [picturesArray addObject:iconPicture];
    self.iconView.picturesArray = picturesArray;
}

@end

